package com.smart_campus.activiti.config;


import org.activiti.engine.ProcessEngine;
import org.activiti.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 项目启动部署流程
 * @aytgor 陈鹏
 * @date 2020/6/28 15:20
 */
@Component
public class DeployProcess implements ApplicationRunner {
    @Autowired
    private ProcessEngine processEngine;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        Deployment deployment = processEngine.getRepositoryService()//获取流程定义和部署对象相关的Service
                .createDeployment()//创建部署对象
                .name("请假申请审核流程")//声明流程的名称
                .addClasspathResource("mapper/leave.bpmn")//加载资源文件，一次只能加载一个文件
                .addClasspathResource("mapper/leave.png")//
                .deploy();//完成部署
        System.out.println("部署完成");
    }
}
